﻿// © 2009 Microsoft Corporation.  All rights reserved.
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

namespace Microsoft.InformationSecurity.RiskManagement.ISRMWeb.UserControls
{
    /// <summary>
    /// Represents a search filter field loaded from configuration.
    /// </summary>
    public class SearchFilterField
    {
        /// <summary>
        /// Name of the field.
        /// </summary>
        public string Name { set; get; }

        /// <summary>
        /// Operators for the field. Each key and value represents a single operator where key is the operator and value is the default flag.
        /// </summary>
        public List<KeyValuePair<string, bool>> Operators { set; get; }

        /// <summary>
        /// Allowed values for the field.
        /// </summary>
        public List<AllowedValue> AllowedValues { set; get; }

        /// <summary>
        /// Display type of the field.
        /// </summary>
        public string DisplayType { set; get; }

        /// <summary>
        /// Name to be displayed in the drop down list
        /// </summary>
        public string DisplayName{ set; get; }

        /// <summary>
        /// Data type of the field.
        /// </summary>
        public string DataType { set; get; }

        /// <summary>
        /// Defines the valid characters for validation.
        /// </summary>
        public string ValidCharacters { set; get; }

        /// <summary>
        /// Returns trye if this field is default.
        /// </summary>
        public bool IsDefault { set; get; }

        /// <summary>
        /// Returns trye if this field value is required
        /// </summary>
        public bool IsRequired { set; get; }

        /// <summary>
        /// Public Constructor.
        /// </summary>
        public SearchFilterField() 
        {
            this.Operators = new List<KeyValuePair<string, bool>>();
            this.AllowedValues = new List<AllowedValue>();
        }
    }

    /// <summary>
    /// Represents an allowable value in the search field.
    /// </summary>
    public class AllowedValue 
    {
        /// <summary>
        /// Key of the allowable value.
        /// </summary>
        public int Key { set; get; }

        /// <summary>
        /// Value of the field.
        /// </summary>
        public string Value { set; get; }

        /// <summary>
        /// Default value of the field if true.
        /// </summary>
        public bool IsDefault { set; get; }

        public AllowedValue() { }

        public AllowedValue(int key, string value, bool isDefault) 
        {
            this.Key = key;
            this.Value = value;
            this.IsDefault = isDefault;
        }
    }
}
